package com.jade.zsy.base.facade.impl;

import com.jade.bss.DbException;
import com.jade.bss.base.utils.CopyBean;
import com.jade.bss.db.impl.BaseFacadeImpl;
import com.jade.framework.base.criterion.Criteria;
import com.jade.framework.base.util.PagingList;
import com.jade.framework.base.util.PagingResult;
import com.jade.zsy.base.dao.SkuSpecDao;
import com.jade.zsy.base.entity.SkuSpec;
import com.jade.zsy.base.facade.SkuSpecFacade;
import com.jade.zsy.base.vo.SkuSpecVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.inject.Inject;
import javax.inject.Named;

/**
 * Created with IntelliJ IDEA.
 * User: jinya
 * Date: 2017/6/3
 * Time: 12:59
 * TEL :17701640710   MAIL:2009_jinya@163.com
 * To change this template use File | Settings | File Templates.
 */
@Service("SkuSpecFacade")
public class SkuSpecFacadeImpl extends BaseFacadeImpl implements SkuSpecFacade {
    @Inject
    @Named("SkuSpecDao")
    private SkuSpecDao entityDao;
    @Override
    @Transactional
    public void save(Object obj) throws DbException {
        SkuSpec entity=(SkuSpec)obj;
        entity.setOwnerId("1");
        super.save(entity);
    }
    @Override
    public PagingResult queryEntity(Object obj, int page, int size, String keys, String... orders) throws DbException,IllegalAccessException, InstantiationException {
        SkuSpecVo entity=(SkuSpecVo)obj;
        Criteria criteria = new Criteria((page - 1) * size, size);

        PagingList pagingList = entityDao.queryEntity(SkuSpec.class, criteria);
        PagingResult  result = PagingResult.getResult(CopyBean.copy(pagingList, SkuSpecVo.class), pagingList.getTotalCount(), page, size);
        return result;
    }
}
